import { FormSchema } from '@/components/Form';
import { BasicColumn } from '@/components/Table';
import { DescItem } from '@/components/Description';
import { DicSortEnum } from '@/enums';
import { listOpManufacturerTypeApi } from '@/api/operations/manufacturertype.api';

/** 表格数据 */
export const columns: BasicColumn[] = [
  {
    title: '分类ID',
    dataIndex: 'typeId',
    width: 220,
  },
  {
    title: '资产名称',
    dataIndex: 'name',
    width: 220,
  },
  {
    title: '资产编号',
    dataIndex: 'assetNumber',
    width: 220,
  },
  {
     title: '厂商名称',
     dataIndex: 'firm',
     width: 220, 
  },
  {
    title: '条码',
    dataIndex: 'barCode',
    width: 220,
  },
  {
    title: '存放位置',
    dataIndex: 'position',
    width: 220,
  },
  {
    title: '规格',
    dataIndex: 'specification',
    width: 220,
  },
  {
    title: '单位',
    dataIndex: 'unit',
    width: 220,
  },
  {
    title: '单价',
    dataIndex: 'price',
    width: 220,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 220,
  },
  {
    title: '数量',
    dataIndex: 'number',
    width: 220,
  },
  {
    title: '相关照片',
    dataIndex: 'picture',
    width: 220,
  },
];

/** 查询数据 */
export const searchFormSchema: FormSchema[] = [
  {
    label: '资产名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '资产编号',
    field: 'assetNumber',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '规格',
    field: 'specification',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '单位',
    field: 'unit',
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: '单价',
    field: 'price',
    component: 'InputNumber',
    colProps: { span: 6 },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Input',
    colProps: { span: 6 },
  },
];

/** 表单数据 */
export const formSchema: FormSchema[] = [
  {
    label: '主键ID',
    field: 'id',
    component: 'Input',
    show: false,
    colProps: { span: 12 },
  },
  {
      label: '资产分类',
      field: 'typeId',
      component: 'ApiTreeSelect',
      componentProps: {
        showSearch: true,
        api: listOpManufacturerTypeApi,
        treeNodeFilterProp: 'typeName',
        labelField: 'typeName',
        valueField: 'id',
        getPopupContainer: () => document.body,
      },
      required: true,
      colProps: { span: 24 },
  },
  {
    label: '资产名称',
    field: 'name',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
  {
    label: '资产编号',
    field: 'assetNumber',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: '规格',
    field: 'specification',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: '单位',
    field: 'unit',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: '厂商名称',
    field: 'firm',
    component: 'Input',
    colProps: { span: 12 },
  },
  {
    label: '条码',
    field: 'barCode',
    component: 'Input',
    colProps: { span: 12 },
  }, 
  {
    label: '存放位置',
    field: 'position',
    component: 'Input', 
    colProps: { span: 12 },
  },
  {
    label: '单价',
    field: 'price',
    component: 'InputNumber',
    defaultValue: DicSortEnum.ZERO,
    colProps: { span: 12 },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Input',
    required: true,
    colProps: { span: 12 },
  },
  {
    label: '数量',
    field: 'number',
    component: 'InputNumber',
    defaultValue: DicSortEnum.ZERO,
    required: true,
    colProps: { span: 12 },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    required: true,
    colProps: { span: 24 },
  },
  {
    label: '相关照片',
    field: 'picture',
    component: 'ImageUpload',
    required: true,
    colProps: { span: 24 },
  },
];

/** 详情数据 */
export const detailSchema: DescItem[] = [
  {
    label: '分类ID',
    field: 'typeId',
    span: 12,
  },
  {
    label: '资产名称',
    field: 'name',
    span: 12,
  },
  {
    label: '资产编号',
    field: 'assetNumber',
    span: 12,
  },
  {
    label: '规格',
    field: 'specification',
    span: 12,
  },
  {
    label: '厂商名称',
    field: 'firm',
    span: 12,
  },
  {
    label: '条码',
    field: 'barCode',
    span: 12,  
  },
  {
    label: '存放位置',
    field: 'position',
    span: 12, 
  },
  {
    label: '单位',
    field: 'unit',
    span: 12,
  },
  {
    label: '单价',
    field: 'price',
    span: 12,
  },
  {
    label: '状态',
    field: 'status',
    span: 12,
  },
  {
    label: '数量',
    field: 'number',
    span: 12,
  },
  {
    label: '备注',
    field: 'remark',
    span: 12,
  },
  {
    label: '相关照片',
    field: 'picture',
    span: 12,
  },
];
